package com.boot.config.easy;

import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.boot.entity.Report;
import lombok.extern.slf4j.Slf4j;

import java.util.ArrayList;
import java.util.List;

/**
 * @description:
 * @author: HuangX
 * @date: 2021/7/14
 */
@Slf4j
public class UploadListener extends AnalysisEventListener<Report> {

    private final List<Report> result = new ArrayList<>();

    @Override
    public void invoke(Report data, AnalysisContext context) {
        result.add(data);
//        if (ObjectUtil.isNotEmpty(data)){
//            BigDecimal amount = data.getAmount();
//            System.out.println("amount.toString() = " + amount.toPlainString());
//            log.info("添加一条有效数据");
//        }

    }

    @Override
    public void doAfterAllAnalysed(AnalysisContext context) {
        log.info("共导入"+result.size()+"条数据");
    }
}
